package com.epam.facebook_client.wrapper;

import common.wrapper.JSONObjectWrapper;

import android.os.Parcel;
import android.os.Parcelable;

public class Feed extends JSONObjectWrapper {

	private static final String ID = "id";
	private static final String NAME = "name";
	private static final String FROM = "from";
	private static final String STORY = "story";
	private static final String PICTURE = "picture";
	private static final String DESCRIPTION = "description";
	private static final String MESSAGE = "message";
	private static final String TYPE = "type";
	private static final String LINK = "link";
	private final static String PAGING = "paging";
	private final static String NEXT = "next";
	private final static String CREATE_TIME = "created_time";

	public Feed() {
		super();
	}

	public Feed(String json) {
		super(json);
	}

	public Feed(Parcel source) {
		this(source.readString());
	}

	public String getId() {
		return getString(ID);
	}

	public String getName() {
		return getJSONObject(FROM).getString(NAME);
	}

	public String getStory() {
		return getString(STORY);
	}

	public String getPicture() {
		return getString(PICTURE);
	}

	public String getDescription() {
		return getString(DESCRIPTION);
	}

	public String getMessage() {
		return getString(MESSAGE);
	}

	public String getType() {
		return getString(TYPE);
	}

	public String getLink() {
		return getString(LINK);
	}
	public String getCreateTime() {
		return getString(CREATE_TIME);
	}

	public String getNext() {
		JSONObjectWrapper jsonObject = getJSONObject(PAGING);
		if (jsonObject != null) {
			return jsonObject.getString(NEXT);
		} else {
			return null;
		}
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(toString());
	}

	public static final Parcelable.Creator<Feed> CREATOR = new Creator<Feed>() {

		@Override
		public Feed createFromParcel(Parcel source) {
			return new Feed(source);
		}

		@Override
		public Feed[] newArray(int size) {
			return new Feed[size];
		}
	};
}
